//
// Created by jiangpenghui on 2023/4/18.
//

#ifndef CMAKECXX_TRASH_H
#define CMAKECXX_TRASH_H

#include <iostream>

class Trash {
    float _weight;
public:
    Trash(float wt) : _weight(wt) {};

    // 虚拟方法
    virtual float value() const = 0;

    float weight() const { return _weight; }

    virtual ~Trash() {
        std::cout << "~Trash()" << std::endl;
    }
};


class Aluminum : public Trash {
    static float val;
public:
    // 子类初始化构造父类
    Aluminum(float wt) : Trash(wt) {
        std::cout << "construction  is Aluminum  Trash" << std::endl;
    }

    float value() const {
        return val;
    }

    static void value(float newval) {
        val = newval;
    }
};


class Paper : public Trash {
    static float val;
public:
    Paper(float wt) : Trash(wt) {
        std::cout << "construction  is Paper  Trash" << std::endl;
    }

    float value() const {
        return val;
    }

    static void value(float newval) {
        val = newval;
    }

};

class Glass : public Trash {
    static float val;
public:
    Glass(float wt) : Trash(wt) {}

    float value() const { return val; }

    static void value(float newval) {
        val = newval;
    }
};

#endif //CMAKECXX_TRASH_H
